package io;

import java.io.*;

public class CopyDemoBuffer {//缓冲流是高级流,加快读写效率
    /*bufferedInputStream:缓冲输入流
    bufferedOutStrEAM:缓冲输出流
    缓冲流快是因为内部有一个8kb的数组(块读写)
    所有高级流里只有缓冲流才能加速,所以其他高级流常和缓冲流一起使用.将功能流链接到缓冲流上

     */
    public static void main(String[] args) throws IOException {
        FileInputStream fis =new FileInputStream("YaeSakura.jpg");
        BufferedInputStream bis=new BufferedInputStream(fis);
        FileOutputStream fos =new FileOutputStream("YaeSakuraMyWife.jpg");
        BufferedOutputStream bos =new BufferedOutputStream(fos);

        long start =System.currentTimeMillis();

        int d;
        while((d=bis.read())!=-1){
            bos.write(d);
        }
        long end =System.currentTimeMillis();
        System.out.println("耗时:"+(end-start)+"ms");
        bis.close();
        bos.close();


    }
}
